:root[data-theme='dark'] {
  --theme-background: #121212;
  --theme-surface: #1e1e1e;
  --theme-surface-variant: #2d2d2d;
  --theme-text: #ffffff;
  --theme-text-secondary: rgba(255, 255, 255, 0.7);
  --theme-primary: #bb86fc;
  --theme-primary-variant: #3700b3;
  --theme-secondary: #03dac6;
  --theme-error: #cf6679;
  --theme-border: rgba(255, 255, 255, 0.1);
  --theme-shadow: rgba(0, 0, 0, 0.2);
  --theme-think: #666;
  --theme-input-bg: #2d2d2d;
  --theme-input-disabled-bg: #2d2d2d;
}

:root[data-theme='light'] {
  --theme-background: #f5f7fa;
  --theme-surface: #ffffff;
  --theme-surface-variant: #fff;
  --theme-text: #333333;
  --theme-text-secondary: rgba(0, 0, 0, 0.45);
  --theme-primary: #1677ff;
  --theme-primary-variant: #0958d9;
  --theme-secondary: #13c2c2;
  --theme-error: #ff4d4f;
  --theme-border: rgba(0, 0, 0, 0.1);
  --theme-shadow: rgba(0, 0, 0, 0.1);
  --theme-think: #999;
  --theme-input-bg: #fff;
  --theme-input-disabled-bg: #f5f7fa;
}

.pageRoot {
  width: 100%;
  height: 100vh;
  background-color: var(--theme-background);
  display: flex;
  flex-direction: column;
  color: var(--theme-text);
  transition: background-color 0.3s ease;
}

.chatContainer {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--theme-background);
  position: relative;
  transition: background-color 0.3s ease;
}

.header {
  height: 44px;
  background: var(--theme-surface);
  color: var(--theme-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: 0 1px 3px var(--theme-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;

  .title {
    font-size: 18px;
    font-weight: 500;
    background: linear-gradient(45deg, var(--theme-primary), var(--theme-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .themeToggle {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--theme-text);
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 16px;
    background: var(--theme-surface-variant);
    transition: all 0.3s ease;

    .themeIcon {
      font-size: 16px;
    }

    .themeText {
      margin-left: 2px;
    }

    &:active {
      transform: scale(0.95);
      background: var(--theme-primary);
      color: white;
    }
  }
}

.messageList {
  flex: 1;
  overflow-y: auto;
  padding: 54px 12px 70px;
  -webkit-overflow-scrolling: touch;

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: var(--theme-background);
  }

  &::-webkit-scrollbar-thumb {
    background: var(--theme-surface-variant);
    border-radius: 3px;
  }

  table {
    width: 100%;
    font-size: 9px;
    border-collapse: collapse;
    margin: 8px 0;
  }
  
  th, td {
    border: 1px solid var(--theme-border);
    padding: 4px 6px;
    text-align: left;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  th {
    background-color: var(--theme-surface-variant);
  }

}

.messageItem {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;

  .avatar {
    width: 36px;
    height: 36px;
    margin-right: 8px;
    border-radius: 18px;
    border: 2px solid var(--theme-primary);
    padding: 2px;
    transition: border-color 0.3s ease;
  }

  .messageContent {
    // max-width: 70%;
    flex: 1;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
    transition: all 0.3s ease;
    overflow: auto;
  }
}

.botMessage {
  .messageContent {
    background-color: var(--theme-surface);
    color: var(--theme-text);
    border-top-left-radius: 4px;
    box-shadow: 0 2px 4px var(--theme-shadow);
  }
}

.userMessage {
  flex-direction: row-reverse;
  .messages {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-primary-variant));
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 2px 4px var(--theme-shadow);
  }
}

.loadingBubble {
  min-width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--theme-surface) !important;
}

.inputArea {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 12px;
  background: var(--theme-surface);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 -1px 3px var(--theme-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;

  .input {
    flex: 1;
    background: var(--theme-input-bg);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 15px;
    border: 1px solid var(--theme-border);
    color: var(--theme-text);
    transition: all 0.3s ease;

    &::placeholder {
      color: var(--theme-text-secondary);
    }

    &:focus {
      background: var(--theme-surface);
      border-color: var(--theme-primary);
    }

    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      background: var(--theme-input-disabled-bg);
    }
  }
  :global(.adm-input-disabled) {
    background: var(--theme-input-disabled-bg);
  }
  .sendButton {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: var(--theme-primary);
    color: white;
    border: none;
    transition: all 0.3s ease;
    margin-left: 5px;
    &:active {
      transform: scale(0.95);
    }

    &.disabled {
      opacity: 0.5;
      cursor: not-allowed;
      background: var(--theme-text-secondary);
    }
  }
}

.darkInput {
  :global(.adm-input-element) {
    color: #fff!important;
  }
}

.messageThink {
  // border-bottom: 1px dashed var(--theme-think);
  color: var(--theme-think);
  padding-bottom: 20px;
  padding: 0 10px;
}


@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.generateTip {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 5px;
}
.waitingTip {
  text-align: center;
}
.animateSpin {
  width: 15px;
  height: 15px;
  animation: spin 1s linear infinite;
  margin-right: 5px;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

:global(.adm-dot-loading) {
  --dot-size: 4px;
  --dot-color: var(--theme-text);
}


.messageText{
  position: relative;
  padding: 0 10px;
  margin-top: 10px;
}

:global{
  body {
    max-width: 600px; /* 设定一个合适的最大宽度 */
    margin: 0 auto; /* 居中显示 */
  }
}

.copyCode {
  width: 100%;
  height: 30px;
  background-color: #1f2937;
  margin-bottom: -10px;
  font-size: 14px;
  color: #e4e4e7;
  display: flex;
  justify-content: right;
  align-items: center;
  padding-right: 6px;
  cursor: pointer;
}